
import pymongo
from common.config import *
class MongoClient():
    name = "toutiao"
    def __init__(self):
        self.client = pymongo.MongoClient(MONGO_CONFIG["mongo_uri"])
        self.db = self.client[MongoClient.name]
    # 写入mongo数据库
    def saveMongo(self, data):
        self.db['news'].update({'title': data['title']}, {'$set': data}, True)
        print("数据存储MongoDB成功:", data["title"])
